from Autotests.LocalMachine.Controls.Button import WebButton
from Autotests.LocalMachine.Controls.LineEdit import WebLineEdit
from Autotests.LocalMachine.Controls.ComboBox import WebComboBox
from Autotests.LocalMachine.UiObjectsMap.AirClient import Options
from Autotests.LocalMachine.Pages.BaseDialog import BaseWebTreeDialog
from OptionsPage import OptionsPage


class Language(object):
    english = "en"
    dutch = "nl_NL"
    russian = "ru_RU"
    german = "de_DE"
    spanish = "es_ES"
    french = "fr_FR"
    hungarian = "hu_HU"
    italian = "it_IT"
    swedish = "sv_SE"
    japanese = "ja_JP"
    portuguese = "pt_PT"
    polish = "pl_PL"
    korean = "ko_KR"
    danish = "da_DK"
    norwegian = "no_NO"
    finnish = "fi_FI"
    chinese_TW = "zh_TW"
    chinese_CN = "zh_CN"


class AdvancedTab(OptionsPage):
    def __init__(self):
        super(AdvancedTab, self).__init__()
        self._comboBoxLanguage = WebComboBox(Options.Advanced.cbLanguage)
        self._textBoxTempDir = WebLineEdit(Options.Advanced.txtBoxTemp)
        self._treeTempDir = BaseWebTreeDialog()

    def goToHomeLocation(self):
        super(AdvancedTab, self).goToHomeLocation()
        WebButton(Options.btnAdvanced).click()

    @OptionsPage.setter
    def setAdvancedSettings(self, language=Language.english, tempDirPath=''):
        self._comboBoxLanguage.selectItemsByDataValue(language)
        if tempDirPath != "":
            self._textBoxTempDir.click()
            self._treeTempDir.setItemSelection(tempDirPath)

    @OptionsPage.getter
    def getAdvancedSettings(self):
        return self._comboBoxLanguage.currentItem().dataValue(), self._textBoxTempDir.text()

